<template>
  <div>
    <el-container>
      <!-- 侧边栏 -->

      <el-aside :width="isCollapse == true ? '67px' : '200px'">
        <div class="log">logo</div>
        <el-menu
          :unique-opened="true"
          :collapse="isCollapse"
          default-active="home"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b"
          :router="true"
        >
          <el-menu-item index="home">
            <i class="el-icon-setting"></i>
            <span slot="title">首页</span>
          </el-menu-item>

          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>表格管理</span>
            </template>

            <el-menu-item-group>
              <el-menu-item index="/basicform">基本表格</el-menu-item>
              <el-menu-item index="1-2">排序表格</el-menu-item>
              <el-menu-item index="1-2">筛选表格</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="s">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>图表管理</span>
            </template>

            <el-menu-item-group>
              <el-menu-item index="/Histogram">柱状图</el-menu-item>
              <el-menu-item index="/linechart">折线图</el-menu-item>
              <el-menu-item index="/piechart">饼状图</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">导航四</span>
          </el-menu-item>
        </el-menu>
        <!--  -->
      </el-aside>
      <el-container>
        <el-header>
          <div>
            <button @click="lab">
              {{ isCollapse == true ? "展开" : "缩小" }}
            </button>
          </div>
          <div>用户名</div>
          <div>
            <button @click="eliminate">退出</button>
          </div>
        </el-header>
        <el-main>
          <!-- 内容展示区 -->
          <div>
            <router-view></router-view>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      isCollapse: false,
    };
  },
  methods: {
    eliminate() {
      // 退出登录且清除tok
      sessionStorage.clear();
      this.$router.push("/login");
    },
    lab() {
      //展开缩小侧边栏
      this.isCollapse = !this.isCollapse;
    },
  },
  beforeRouteEnter(to, from, next) {
    //判断是否右tok值
    var tok = sessionStorage.getItem("tok");
    tok == null ? next("/login") : next();
  },
};
</script>
<style scoped>
.el-header,
.el-footer {
  background-color: #fff;
  color: #333;

  line-height: 60px;
}
.el-header {
  text-align: right;
}
.el-header div {
  display: inline-block;
  width: 20%;
  text-align: center;
}
.el-aside {
  background-color: rgb(84, 92, 100);
  color: #333;
  text-align: center;
  height: 500px !important;
}

.el-main {
  background-color: #eee;
  color: #333;

  line-height: 15px;
}
.el-main div {
  width: 99%;
  height: 99%;
  margin: auto;
  background: seashell;
}

body > .el-container {
  margin-bottom: 40px;
}
.el-header > div:nth-of-type(1) {
  width: 60%;
  text-align: left;
}
.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.log {
  width: 100%;
  height: 9.6vh;
  background: rgb(84, 92, 100);
  text-align: center;
  font-size: 25px;
  line-height: 10vh;
  font-weight: 900;
  color: #f123;
}
</style>